% File: testbench_sc_fde_ib_evolution_buf.m
% -----------------------------------------
% This script draw traces of evolutional statistics.

close all
clear all

% load testbench_sc_fde_ib_evolution_buf.mat
% load testbench_sc_fde_ib_evolution_buf2.mat
load testbench_sc_fde_ib_evolution_buf3.mat
% load testbench_sc_fde_ib_evolution_buf_fip.mat
% load testbench_sc_fde_ib_evolution_buf_fip_eb_n0_10_20.mat % only snr, var.
% load testbench_sc_fde_ib_evolution_buf_fip_eb_n0_16.mat
% load testbench_sc_fde_ib_evolution_buf_fip_eb_n0_20_24_genie.mat
% load testbench_sc_fde_ib_evolution_buf_fip_eb_n0_20_24_cvfit.mat
% load testbench_sc_fde_ib_evolution_show_case_buf_fip_4qam_12dB.mat

% snr_buf  = SNR_BUF;
% snr_tbuf = SNR_TBUF;
% var_buf  = VAR_BUF;
% var_tbuf = VAR_TBUF;
% mse_buf  = MSE_BUF;
% mse_tbuf = MSE_TBUF;

% SNR_BUF  = [snr_buf; SNR_BUF];
% SNR_TBUF = [snr_tbuf; SNR_TBUF];
% MSE_BUF  = [mse_buf; MSE_BUF];
% MSE_TBUF = [mse_tbuf; MSE_TBUF];
% VAR_BUF  = [var_buf; VAR_BUF];
% VAR_TBUF = [var_tbuf; VAR_TBUF];

% figure();
% semilogx(VAR_BUF(1,:), SNR_BUF(1,:), '-.p', VAR_BUF(2,:), SNR_BUF(2,:), '-.p', VAR_BUF(3,:), SNR_BUF(3,:), '-.p', VAR_BUF(4,:), SNR_BUF(4,:), '-.p', VAR_BUF(5,:), SNR_BUF(5,:), '-.p');
% set(gca,'XDir','reverse')
% xlabel('Average Variance'); ylabel('SNR');
% grid on
% legend('Trace @ 12dB','Trace @ 14dB','Trace @ 16dB','Trace @ 18dB','Trace @ 20dB', 'Location', 'SouthEast');
% title('Evolutional Chart of Iterative Process (Algo.)');
% 
% figure();
% semilogx(VAR_TBUF(1,:), SNR_TBUF(1,:), '-.p', VAR_TBUF(2,:), SNR_TBUF(2,:), '-.p', VAR_TBUF(3,:), SNR_TBUF(3,:), '-.p', VAR_TBUF(4,:), SNR_TBUF(4,:), '-.p', VAR_TBUF(5,:), SNR_TBUF(5,:), '-.p');
% set(gca,'XDir','reverse')
% xlabel('Average Variance'); ylabel('SNR');
% grid on
% legend('Trace @ 12dB','Trace @ 14dB','Trace @ 16dB','Trace @ 18dB','Trace @ 20dB', 'Location', 'SouthEast');
% title('Evolutional Chart of Iterative Process (Test)');

Trace_SNR_BUF = zeros(size(SNR_BUF,1),2*size(SNR_BUF,2));
Trace_SNR_BUF(:,(1: 2: size(Trace_SNR_BUF,2)-1)) = SNR_BUF;
Trace_SNR_BUF(:,(2: 2: size(Trace_SNR_BUF,2)))   = SNR_BUF;

Trace_VAR_BUF = zeros(size(Trace_SNR_BUF));
Trace_VAR_BUF(:,1) = ones(size(Trace_VAR_BUF,1),1);
Trace_VAR_BUF(:,(3: 2: size(Trace_SNR_BUF,2)-1)) = VAR_BUF(:,(1: end-1));
Trace_VAR_BUF(:,(2: 2: size(Trace_SNR_BUF,2)))   = VAR_BUF;

% figure();
% semilogx(Trace_VAR_BUF(1,:), Trace_SNR_BUF(1,:), '-.s', Trace_VAR_BUF(2,:), Trace_SNR_BUF(2,:), '-.s', Trace_VAR_BUF(3,:), Trace_SNR_BUF(3,:), '-.s');
% set(gca,'XDir','reverse')
% xlabel('Average Variance'); ylabel('SNR');
% grid on
% legend('Trace @ 20dB','Trace @ 22dB','Trace @ 24dB', 'Location', 'SouthEast');
% title('Evolutional Chart of Iterative Process (Algo.)');

% figure();
% semilogx(Trace_VAR_BUF(1,:), Trace_SNR_BUF(1,:), '-.s');
% set(gca,'XDir','reverse')
% xlabel('Average Variance'); ylabel('SNR');
% grid on
% legend('Trace @ 16dB', 'Location', 'SouthEast');
% title('Evolutional Chart of Iterative Process (Algo.)');

% figure();
% semilogx(Trace_VAR_BUF(1,:), Trace_SNR_BUF(1,:), '-.s', Trace_VAR_BUF(2,:), Trace_SNR_BUF(2,:), '-.s', Trace_VAR_BUF(3,:), Trace_SNR_BUF(3,:), '-.s', Trace_VAR_BUF(4,:), Trace_SNR_BUF(4,:), '-.s', Trace_VAR_BUF(5,:), Trace_SNR_BUF(5,:), '-.s');
% set(gca,'XDir','reverse')
% xlabel('Average Variance'); ylabel('SNR');
% grid on
% legend('Trace @ 12dB','Trace @ 14dB','Trace @ 16dB','Trace @ 18dB','Trace @ 20dB', 'Location', 'SouthEast');
% title('Evolutional Chart of Iterative Process (Algo.)');

figure();
semilogx(Trace_VAR_BUF(1,:), Trace_SNR_BUF(1,:), '-.s', Trace_VAR_BUF(2,:), Trace_SNR_BUF(2,:), '-.s', Trace_VAR_BUF(3,:), Trace_SNR_BUF(3,:), '-.s', Trace_VAR_BUF(4,:), Trace_SNR_BUF(4,:), '-.s', Trace_VAR_BUF(5,:), Trace_SNR_BUF(5,:), '-.s', Trace_VAR_BUF(6,:), Trace_SNR_BUF(6,:), '-.s');
set(gca,'XDir','reverse')
xlabel('Average Variance'); ylabel('SNR');
grid on
legend('Trace @ 10dB','Trace @ 12dB','Trace @ 14dB','Trace @ 16dB','Trace @ 18dB','Trace @ 20dB', 'Location', 'SouthEast');
title('Evolutional Chart of Iterative Process (Algo.)');

Trace_SNR_TBUF = zeros(size(SNR_TBUF,1),2*size(SNR_TBUF,2));
Trace_SNR_TBUF(:,(1: 2: size(Trace_SNR_TBUF,2)-1)) = SNR_TBUF;
Trace_SNR_TBUF(:,(2: 2: size(Trace_SNR_TBUF,2)))   = SNR_TBUF;

Trace_VAR_TBUF = zeros(size(Trace_SNR_TBUF));
Trace_VAR_TBUF(:,1) = ones(size(Trace_VAR_TBUF,1),1);
Trace_VAR_TBUF(:,(3: 2: size(Trace_VAR_TBUF,2)-1)) = VAR_TBUF(:,(1: end-1));
Trace_VAR_TBUF(:,(2: 2: size(Trace_VAR_TBUF,2)))   = VAR_TBUF;

% figure();
% semilogx(Trace_VAR_TBUF(1,:), Trace_SNR_TBUF(1,:), '-.o', Trace_VAR_TBUF(2,:), Trace_SNR_TBUF(2,:), '-.o', Trace_VAR_TBUF(3,:), Trace_SNR_TBUF(3,:), '-.o');
% set(gca,'XDir','reverse')
% xlabel('Average Variance'); ylabel('SNR');
% grid on
% legend('Trace @ 20dB','Trace @ 22dB','Trace @ 24dB', 'Location', 'SouthEast');
% title('Evolutional Chart of Iterative Process (Test)');

% figure();
% semilogx(Trace_VAR_TBUF(4,:), Trace_SNR_TBUF(4,:), '-.o');
% set(gca,'XDir','reverse')
% xlabel('Average Variance'); ylabel('SNR');
% grid on
% legend('Trace @ 16dB', 'Location', 'SouthEast');
% title('Evolutional Chart of Iterative Process (Test)');

% figure();
% semilogx(Trace_VAR_TBUF(1,:), Trace_SNR_TBUF(1,:), '-.o', Trace_VAR_TBUF(2,:), Trace_SNR_TBUF(2,:), '-.o', Trace_VAR_TBUF(3,:), Trace_SNR_TBUF(3,:), '-.o', Trace_VAR_TBUF(4,:), Trace_SNR_TBUF(4,:), '-.o', Trace_VAR_TBUF(5,:), Trace_SNR_TBUF(5,:), '-.o');
% set(gca,'XDir','reverse')
% xlabel('Average Variance'); ylabel('SNR');
% grid on
% legend('Trace @ 12dB','Trace @ 14dB','Trace @ 16dB','Trace @ 18dB','Trace @ 20dB', 'Location', 'SouthEast');
% title('Evolutional Chart of Iterative Process (Test)');

figure();
semilogx(Trace_VAR_TBUF(1,:), Trace_SNR_TBUF(1,:), '-.o', Trace_VAR_TBUF(2,:), Trace_SNR_TBUF(2,:), '-.o', Trace_VAR_TBUF(3,:), Trace_SNR_TBUF(3,:), '-.o', Trace_VAR_TBUF(4,:), Trace_SNR_TBUF(4,:), '-.o', Trace_VAR_TBUF(5,:), Trace_SNR_TBUF(5,:), '-.o', Trace_VAR_TBUF(6,:), Trace_SNR_TBUF(6,:), '-.o');
set(gca,'XDir','reverse')
xlabel('Average Variance'); ylabel('SNR');
grid on
legend('Trace @ 10dB','Trace @ 12dB','Trace @ 14dB','Trace @ 16dB','Trace @ 18dB','Trace @ 20dB', 'Location', 'SouthEast');
title('Evolutional Chart of Iterative Process (Test)');

% End of script.